package com.fjwt.gz.service.activity.fans;

import com.fjwt.gz.db.dto.StatMemberInfoDTO;
import com.fjwt.gz.db.entity.SysExportTaskEntity;
import com.fjwt.gz.service.activity.AbstractExportReport;
import com.fjwt.gz.service.impl.StatMemberInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 全量用户导出
 */
@Slf4j
@Service
public class MemberInfoExportReport extends AbstractExportReport<StatMemberInfoDTO> {
    @Autowired
    private StatMemberInfoService memberInfoService;
    private static final Map<String, String> HEADER_ALIAS_MAP = new HashMap<>();
    static {
        HEADER_ALIAS_MAP.put("fansId", "客户ID");
        HEADER_ALIAS_MAP.put("cstmName", "姓名");
        HEADER_ALIAS_MAP.put("phone", "手机号");
        HEADER_ALIAS_MAP.put("createdTime", "创建时间");
        HEADER_ALIAS_MAP.put("isAuth", "实名状态");
        HEADER_ALIAS_MAP.put("agentNo4", "网点机构号");
        HEADER_ALIAS_MAP.put("agentName4", "网点机构名称");
        HEADER_ALIAS_MAP.put("agentNo3", "区县机构号");
        HEADER_ALIAS_MAP.put("agentName3", "区县机构名称");
        HEADER_ALIAS_MAP.put("addWeek", "会员周新增");
        HEADER_ALIAS_MAP.put("addMonth", "会员月新增");
        HEADER_ALIAS_MAP.put("addYear", "会员年新增");
        HEADER_ALIAS_MAP.put("cstmNo", "信息局唯一标识");
        HEADER_ALIAS_MAP.put("cstmTime", "实名时间");
        HEADER_ALIAS_MAP.put("isMemberSync","是否迁移客户");
        HEADER_ALIAS_MAP.put("authWeek", "实名周新增");
        HEADER_ALIAS_MAP.put("authMonth", "实名月新增");
        HEADER_ALIAS_MAP.put("authYear", "实名年新增");
    }

    /**
     * 存量会员导出
     * @param sysExportTaskEntity
     * @return
     */
    @Override
    public String exportActivityExcel(SysExportTaskEntity sysExportTaskEntity) {
        StatMemberInfoDTO dto = getRequestParam(sysExportTaskEntity.getRequestParam(),StatMemberInfoDTO.class);
        //存量会员信息
        List<StatMemberInfoDTO> list = memberInfoService.allMemberInfoList(dto);
        return createExcelAndUploadOssUrl(list, HEADER_ALIAS_MAP, sysExportTaskEntity);
    }
}
